package com.galaxy.provider.order.api;

import com.galaxy.provider.order.api.fallback.UserFeignFallback;
import com.galaxy.provider.order.config.FeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 标明feign调用的微服务名称,通过@ FeignClient（"服务名"），来指定调用哪个服务。
 * fallback  出现错误回调类
 *
 * @author caijb
 * @version 1.0.0
 * @date 2018-10-19 13:56
 */
@FeignClient(name = "user-service", fallback = UserFeignFallback.class, configuration = FeignConfig.class)
public interface UserFeignClient {

    /**
     * 对应service-user微服务中的URL
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/getUser/{id}", method = RequestMethod.GET)
    String getUser(@PathVariable("id") String id);

    /**
     * 对应service-user微服务中的URL
     *
     * @return
     */
    @GetMapping(value = "/getAll")
    String listUsers();
}
